package com.acme;

import com.acme.domain.Bank;
import com.acme.domain.account.Account;
import com.acme.domain.account.CheckingAccount;
import com.acme.domain.account.SavingAccount;
import com.acme.domain.client.*;
import com.acme.exceptions.ClientExistsException;
import com.acme.exceptions.NotEnoughFundsException;
import com.acme.exceptions.OverDraftLimitExceededException;

public class BankApplication {

	public static void main(String[] args) throws ClientExistsException,
			NotEnoughFundsException {
		Bank bank = new Bank();

		Client client = new Client("Basil", Gender.MALE);
		Client client2 = new Client("Basil", Gender.MALE);
		bank.addClient(client);

		Account r = new SavingAccount(2, 4500);
		Account t = new CheckingAccount(1, 2000, 3000);
		client.addAccount(t);
		client.addAccount(r);

		try {
			bank.addClient(client2);
		} catch (ClientExistsException e) {
			System.out.println(e.getMessage());
		}

		try {
			t.withdraw(9000);
		} catch (OverDraftLimitExceededException e) {
			System.out.println(e.getOverdraftError());
			e.getClientBalance();
			e.getClientOverdraft();
			e.maxClientSum();

		} catch (IllegalArgumentException e) {
			System.out.println(e.getMessage());
		}

		try {
			r.withdraw(-5000);
		} catch (NotEnoughFundsException e) {
			System.out.println(e.getAmountError());
		} catch (IllegalArgumentException e) {
			System.out.println(e.getMessage());
		}

	}
}